From d611593ffdb064262ecbe85cdf16c5f6345f5858 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Tue, 2 Nov 1999 22:01:43 +0000 Subject: [PATCH] Allow using $TBF_READLEN to specify the size of the chunks that are read * src/testpixbuf.c: Allow using $TBF_READLEN to specify the size of the chunks that are read from the input file. --- demos/testpixbuf.c | 29 +++++++++++++++++------------ gdk-pixbuf/ChangeLog | 4 ++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/demos/testpixbuf.c b/demos/testpixbuf.c index 7309a41a92..350b4cba1e 100644 --- a/demos/testpixbuf.c +++ b/demos/testpixbuf.c @@ -439,11 +439,13 @@ progressive_prepared_callback(GdkPixbufLoader* loader, gpointer data) return; } +static int readlen = 1; + int main (int argc, char **argv) { int i; - int found_valid = FALSE; + int found_valid = FALSE; GdkPixbuf *pixbuf; GdkPixbufLoader *pixbuf_loader; @@ -460,6 +462,11 @@ main (int argc, char **argv) gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); gtk_widget_set_default_visual (gdk_rgb_get_visual ()); + { + char *tbf_readlen = getenv("TBF_READLEN"); + if(tbf_readlen) readlen = atoi(tbf_readlen); + } + i = 1; if (argc == 1) { const gchar*** xpmp; @@ -494,6 +501,7 @@ main (int argc, char **argv) { GtkWidget* rgb_window = NULL; guint timeout; + char *buf; pixbuf_loader = gdk_pixbuf_loader_new (); @@ -506,25 +514,22 @@ main (int argc, char **argv) file = fopen (argv[1], "r"); g_assert (file != NULL); + buf = g_malloc(readlen); - while (TRUE) { - val = fgetc (file); - if (val == EOF) - break; - buf = (guint) val; - - fflush(stdout); + while (!feof(file)) { + int nbytes; + nbytes = fread(buf, 1, readlen, file); printf("."); fflush(stdout); - if (gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (pixbuf_loader), &buf, 1) == FALSE) + if (gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (pixbuf_loader), buf, nbytes) == FALSE) break; - while (gtk_events_pending()) - gtk_main_iteration(); - + while (gtk_events_pending()) + gtk_main_iteration(); } + printf("\n"); gtk_timeout_remove (timeout); gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (pixbuf_loader)); gtk_object_destroy (GTK_OBJECT(pixbuf_loader)); diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index c13270fef3..d622eac6b8 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,7 @@ +1999-11-02 Elliot Lee + * src/testpixbuf.c: Allow using $TBF_READLEN to specify the size of the chunks + that are read from the input file. + 1999-11-02 Larry Ewing * src/gnome-canvas-pixbuf.c (gnome_canvas_pixbuf_render): add aa -- 2.30.2